import InitHandler from "../global/InitHandler";

/**
 * 解析图标
 * @param data 需要处理图标的数据类型
 */
export const parseIcon = (data: any[]): any => {
    const IconFont = InitHandler.getInstance().getIconFont() ;
    //TODO: 为什么这里的data是any类型,这个函数很危险
    if (data === void 0) {
        return void 0;
    }

    let mt: any[] = [] ;
    data.forEach(item => {
        let temp = {...item,icon: <IconFont type={item.icon as string}/>};
        mt.push(temp) ;
        if (item.children && item.children.length > 0){
            let mtc = parseIcon(item.children);
            temp.children = mtc ;
        }
    }) ;
        return mt ;
} ;

